package com.bungarus.group.cachestore;

import org.springframework.stereotype.Component;

import java.io.Serializable;
import java.util.Objects;

@Component
public class StoreColumn implements Serializable {
    private String columnName;
    private String columnValue;

    public static Builder newBuilder() {
        return new Builder();
    }

    @Override
    public String toString() {
        return "StoreColumn{" +
                "columnName='" + columnName + '\'' +
                ", columnValue='" + columnValue + '\'' +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        StoreColumn that = (StoreColumn) o;
        return Objects.equals(columnName, that.columnName) &&
                Objects.equals(columnValue, that.columnValue);
    }

    @Override
    public int hashCode() {
        return Objects.hash(columnName, columnValue);
    }

    public String getColumnName() {
        return columnName;
    }

    public void setColumnName(String columnName) {
        this.columnName = columnName;
    }

    public String getColumnValue() {
        return columnValue;
    }

    public void setColumnValue(String columnValue) {
        this.columnValue = columnValue;
    }

    public static class Builder {
        private StoreColumn column = new StoreColumn();

        public Builder name(String columnName) {
            column.setColumnName(columnName);
            return this;
        }

        public Builder value(String value) {
            column.setColumnValue(value);
            return this;
        }

        public StoreColumn build() {
            return column;
        }
    }
}
